import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import './patientchoose.css'
import { AtCheckbox, AtButton } from "taro-ui"
import reactMixin from 'react-mixin';
import myJs from './patientchooseJs.js'
import app from '../../../../main.js'

export default class PatientChoose extends Component {

  config = {
    navigationBarTitleText: '病人可选标签'
  }
  constructor() {
    super(...arguments);
    this.state = this.getData();
  }
  init() {
    this.setState({
      checkedList: []
    });
  }
  updateLabel = () => {
    app.redirectTo('../labelManage2/labelManage2');
  }
  save = () => {
    Taro.navigateBack({
      delta: 1
    })
  }

  render() {
    return (
      <View className='patient-choose'>
        <View className='tip'>
          勾选上可见标签，患者在关注你时自己就会选择合适的标签
        </View>
        <AtCheckbox
          options={
            this.state.labels.items.map(item => {
              return {
                label: item.name,
                value:item.id
              }
            })
          }
          className=' class_1'
          selectedList={this.state.checkedList}
          onChange={this.handleChange.bind(this, 'checkedList')}
        >
        </AtCheckbox>
        <View className='tip'>
          需要修改患者标签，可以<Text className='a-tag' onClick={this.updateLabel}>点击此处对患者标签进行管理</Text>
        </View>
        <AtButton full={true} className='save-btn' onClick={this.save}>保存</AtButton>
      </View>
    )
  }
}
reactMixin.onClass(PatientChoose, myJs);
